class Solution
{
public:
    int maxDivScore(vector<int> &nums, vector<int> &divisors)
    {
        int maxDivScore = 0;
        int maxDivScoreNum = divisors[0];
        for (int i = 0; i < divisors.size(); ++i)
        {
            int divScore = 0;
            for (int j = 0; j < nums.size(); ++j)
            {
                if (nums[j] % divisors[i] == 0)
                {
                    ++divScore;
                }
            }
            if (divScore > maxDivScore)
            {
                maxDivScore = divScore;
                maxDivScoreNum = divisors[i];
            }
            else if (divScore == maxDivScore)
            {
                maxDivScoreNum = min(maxDivScoreNum, divisors[i]);
            }
        }
        return maxDivScoreNum;
    }
};